<template>
  <div class="photo-grid-wrapper">
    <div class="photo-grid">
      <template v-for="(item, index) in value">
        <PhotoGridItem :urls="item.urls" :key="index"></PhotoGridItem>
      </template>
    </div>
    <div class="more" v-if="hasMore">
      <div class="loader">
        <div class="ball-scale-multiple">
          <div></div>
          <div></div>
          <div></div>
        </div>
      </div>
    </div>
    <div class="more" v-else>没有更多了</div>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import PhotoGridItem from './PhotoGridItem.vue'

@Component({
  components: {
    PhotoGridItem
  }
})
export default class PhotoGrid extends Vue {
  @Prop({ default: [] })
  value: any[]

  @Prop({ default: true })
  hasMore: boolean
}
</script>

<style lang="scss" scoped>
.photo-grid-wrapper {
  .photo-grid {
    display: flex;
    flex: 1;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .more {
    width: 100%;
    padding: 40px 0;
    text-align: center;
    font-size: 14px;
    color: #999;

    .loader {
      display: flex;
      justify-content: center;
    }

    @-webkit-keyframes ball-scale-multiple {
      0% {
        -webkit-transform: scale(0);
        transform: scale(0);
        opacity: 0;
      }
      5% {
        opacity: 1;
      }
      100% {
        -webkit-transform: scale(1);
        transform: scale(1);
        opacity: 0;
      }
    }

    @keyframes ball-scale-multiple {
      0% {
        -webkit-transform: scale(0);
        transform: scale(0);
        opacity: 0;
      }
      5% {
        opacity: 1;
      }
      100% {
        -webkit-transform: scale(1);
        transform: scale(1);
        opacity: 0;
      }
    }

    .ball-scale-multiple {
      position: relative;
      -webkit-transform: translateY(-20px);
      transform: translateY(-20px);
    }

    .ball-scale-multiple > div:nth-child(2) {
      -webkit-animation-delay: -0.4s;
      animation-delay: -0.4s;
    }

    .ball-scale-multiple > div:nth-child(3) {
      -webkit-animation-delay: -0.2s;
      animation-delay: -0.2s;
    }

    .ball-scale-multiple > div {
      background-color: #999;
      border-radius: 100%;
      -webkit-animation-fill-mode: both;
      animation-fill-mode: both;
      position: absolute;
      left: -20px;
      top: 0;
      opacity: 0;
      margin: 0;
      width: 40px;
      height: 40px;
      -webkit-animation: ball-scale-multiple 1s 0s linear infinite;
      animation: ball-scale-multiple 1s 0s linear infinite;
    }
  }
}
</style>
